using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraEditors.Controls;
using System.IO;
namespace ePlanSysOman
{
  public partial class frmProgram
  {
      
    private void  // ERROR: Handles clauses are not supported in C#
OK_Button_Click(System.Object sender, System.EventArgs e)
    {
      this.DialogResult = System.Windows.Forms.DialogResult.OK;
      clsData dc = new clsData();
      if (TextEdit1.Text == "") {
        DevExpress.XtraEditors.XtraMessageBox.Show("You must type a name !", "", MessageBoxButtons.OK);
      } else {

        dc.ExecuteSQL("insert into tblProgram (description,ecp,Country) values ('" + TextEdit1.Text + "','" + TextEdit2.Text + "','" + cmbCountry.Text + "')");
        Module1.newModule.Country = cmbCountry.Text;
      }

      this.Close();
    }

    private void  // ERROR: Handles clauses are not supported in C#
Cancel_Button_Click(System.Object sender, System.EventArgs e)
    {
      this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
      this.Close();
    }

    private void FillCountry()
    {


      ImageComboBoxItem itm;
      clsData vlt = new clsData();

      DataSet ds;
      int i;
      int Vlaves;

      //Retrieve programs

      ds = vlt.getData("select * from tblCountry order by country");

      //Populate combo box
      Vlaves = ds.Tables[0].Rows.Count;
      for (i = 0; i <= Vlaves - 1; i++) {
        itm = new ImageComboBoxItem();
        itm.Value = ds.Tables[0].Rows[i]["ID"];
        itm.Description = ds.Tables[0].Rows[i]["COUNTRY"].ToString();
        cmbCountry.Properties.Items.Add(itm);
      }

      //Dispose objects
      vlt = null;
      ds.Dispose();
      ds = null;
    }

    private void  // ERROR: Handles clauses are not supported in C#
frmProgram_Load(object sender, System.EventArgs e)
    {
      FillCountry();
    }

    private void  // ERROR: Handles clauses are not supported in C#
cmbCountry_SelectedIndexChanged(System.Object sender, System.EventArgs e)
    {
      Module1.newModule.CountryId = Conversions.ToInteger(cmbCountry.EditValue);
      frmDetail FRM = new frmDetail();
      FRM.Show();

    }

      public frmProgram()
    {
        InitializeComponent(); 
    }
  }
}

